Skip to content

feat(event): support multi-event view with newline-separated IDs (CLI-1HT)#903

Merged
BYK merged 6 commits intomainfrom
byk/fix-cli-1ht-embedded-newlines
May 1, 2026
Merged

feat(event): support multi-event view with newline-separated IDs (CLI-1HT)#903
BYK merged 6 commits intomainfrom
byk/fix-cli-1ht-embedded-newlines

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented May 1, 2026

Summary

  • Support viewing multiple events when agents paste newline-separated IDs
  • Fetch all events in parallel with bounded concurrency (pLimit(5))
  • Backward-compatible JSON: single event → flat object, multiple → array
  • Extract shared splitNewlineArg utility from duplicated code in log view

Motivation

CLI-1HT: A Codex agent passed 45 event IDs as a single newline-separated argument to sentry event view:

perzimo/perzimo-server/189945b37884462cb9134bd5cabeaa3d\n60c277e6c73f41c58ca46231b46dc0f8\n...

After splitting on the last /, the extracted id contained embedded newlines which triggered rejectControlCharsValidationError.

Instead of stripping extra IDs, this treats the input as a multi-event request — matching how log view already handles newline-separated IDs.

Changes

src/commands/event/view.ts

  • expandNewlineArgs — splits each positional arg on newlines (via shared splitNewlineArg)
  • collectEventIds — validates extra hex IDs, deduplicates, skips invalid ones
  • fetchMultipleEvents — parallel fetch with pLimit(5) concurrency cap, per-ID failure handling
  • parsePositionalArgs — detects expanded org/project/id args (2+ slashes) and routes through single-arg path; collects extraEventIds from remaining args (including swapped-args path)
  • EventViewData — wraps events: SingleEventViewData[] + requestedCount for deterministic JSON shape even on partial failures
  • jsonTransformEventView — uses requestedCount (not events.length) to decide flat object vs array, preventing non-deterministic shape changes on partial fetch failures
  • formatEventView — renders multiple events separated by ---
  • --web flag — warns when extra event IDs are ignored (only first opens)

src/lib/arg-parsing.ts

  • splitNewlineArg — shared utility for splitting newline-separated args (replaces duplicated splitLogIds in log/view.ts)

src/commands/log/view.ts

  • Replace splitLogIds with direct splitNewlineArg calls

Tests

  • 30+ new tests covering splitNewlineArg, expandNewlineArgs, collectEventIds (including dedup), formatEventView (multi-event, span trees), jsonTransformEventView (single/multi/partial-failure/field-filtering), fetchMultipleEvents (success/prefetch/partial-failure/all-fail), parsePositionalArgs extra IDs (normal/swapped/2+-slash paths)

Fixes CLI-1HT

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-903/

Built to branch gh-pages at 2026-05-01 23:21 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Codecov Results 📊

6569 passed | Total: 6569 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +39
Passed Tests 📈 +39
Failed Tests
Skipped Tests

All tests are passing successfully.

❌ Patch coverage is 79.88%. Project has 13346 uncovered lines.
✅ Project coverage is 76.06%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/commands/event/view.ts 78.75% ⚠️ 34 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    76.02%    76.06%    +0.04%
==========================================
  Files          296       296         —
  Lines        55640     55745      +105
  Branches         0         0         —
==========================================
+ Hits         42298     42399      +101
- Misses       13342     13346        +4
- Partials         0         0         —

Generated by Codecov Action

Comment thread src/lib/arg-parsing.ts Outdated
@BYK BYK force-pushed the byk/fix-cli-1ht-embedded-newlines branch from 55b4790 to c1455b8 Compare May 1, 2026 06:23
@BYK BYK changed the title fix(arg-parsing): strip embedded newlines from structured arg IDs (CLI-1HT) feat(event): support multi-event view with newline-separated IDs (CLI-1HT) May 1, 2026
Comment thread src/commands/event/view.ts
Comment thread src/commands/event/view.ts
Comment thread src/commands/event/view.ts Outdated
@BYK BYK force-pushed the byk/fix-cli-1ht-embedded-newlines branch from c1455b8 to 249a176 Compare May 1, 2026 21:09
…-1HT)

Agents (Codex) sometimes paste multiple event IDs as a single
newline-separated argument, e.g. `org/project/id1\nid2\nid3`.
Instead of rejecting the input with a ValidationError, expand
newline-separated args and fetch all events in parallel.

Changes:
- Add `expandNewlineArgs` to split newline-separated positional args
- Change `parsePositionalArgs` to collect extra event IDs beyond the
  first two args into `extraEventIds`
- Add `collectEventIds` and `fetchMultipleEvents` helpers for parallel
  multi-event fetching with per-ID failure handling
- Change output type to `{ events: SingleEventViewData[] }` — single
  event yields flat JSON (backward compat), multiple events yield array
- Update human formatter to separate multiple events with `---`

Fixes CLI-1HT
@BYK BYK force-pushed the byk/fix-cli-1ht-embedded-newlines branch from 249a176 to e9b90ee Compare May 1, 2026 21:30
Comment thread src/commands/event/view.ts
…xtraEventIds

- Export and test splitOnNewlines, expandNewlineArgs, collectEventIds,
  formatEventView, jsonTransformEventView, fetchMultipleEvents
- Test formatEventView with span tree lines and multi-event separator
- Test jsonTransformEventView single vs multi-event and field filtering
- Test fetchMultipleEvents success, prefetch, partial failure, all-fail
- Test parsePositionalArgs extraEventIds in swap-detected path
- Patch coverage at 91%+ (remaining uncovered: func() integration paths)
Comment thread src/commands/event/view.ts
Comment thread src/commands/event/view.ts Outdated
…extract shared splitNewlineArg

Fix bug where expanded 'org/project/id1\nid2' was incorrectly parsed
with first arg as target (losing id1). When the first arg has 2+ slashes,
route through parseSingleArg to correctly split org/project from id.

Extract splitNewlineArg to src/lib/arg-parsing.ts as a shared utility,
replacing the duplicate splitLogIds in log/view.ts and splitOnNewlines
in event/view.ts.
Comment thread src/commands/event/view.ts
…l failure

When multiple events are requested but some fail, the JSON output shape
should be deterministic based on what was requested, not what succeeded.
Use requestedCount (from allEventIds.length) instead of events.length
to decide flat object vs array format.

Also extract splitNewlineArg to src/lib/arg-parsing.ts as shared utility,
replacing duplicates in event/view.ts and log/view.ts.
Comment thread src/commands/event/view.ts
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 08099f6. Configure here.

Comment thread src/commands/event/view.ts
BYK added 2 commits May 1, 2026 22:17
Agent-pasted lists often contain duplicate IDs. Deduplicate using a Set
to avoid redundant API fetches and duplicate output entries.
…g, relocate tests

Address self-review findings:
- Warn when --web flag is used with extra event IDs (only first opens)
- Replace splitLogIds alias with direct splitNewlineArg calls in log/view.ts
- Move splitNewlineArg tests to test/lib/arg-parsing.test.ts (correct location)
- Remove orphaned JSDoc block from log/view.ts
Comment thread src/commands/event/view.ts
@BYK BYK merged commit c51501d into main May 1, 2026
26 checks passed
@BYK BYK deleted the byk/fix-cli-1ht-embedded-newlines branch May 1, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant